-- This script was generated by the Schema Diff utility in pgAdmin 4
-- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated
-- and may require manual changes to the script to ensure changes are applied in the correct order.
-- Please report an issue for any failure with the reproduction steps.
CREATE TABLE IF NOT EXISTS public.helicone_api_keys
(
    created_at timestamp with time zone NOT NULL DEFAULT now(),
    api_key_hash text COLLATE pg_catalog."default" NOT NULL,
    api_key_name text COLLATE pg_catalog."default" NOT NULL,
    user_id uuid NOT NULL,
    CONSTRAINT helicone_api_keys_pkey PRIMARY KEY (api_key_hash),
    CONSTRAINT helicone_api_keys_user_id_fkey FOREIGN KEY (user_id)
        REFERENCES auth.users (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION

);

ALTER TABLE IF EXISTS public.helicone_api_keys
    OWNER to postgres;

ALTER TABLE IF EXISTS public.helicone_api_keys
    ENABLE ROW LEVEL SECURITY;

GRANT ALL ON TABLE public.helicone_api_keys TO anon;

GRANT ALL ON TABLE public.helicone_api_keys TO authenticated;

GRANT ALL ON TABLE public.helicone_api_keys TO postgres;

GRANT ALL ON TABLE public.helicone_api_keys TO service_role;




CREATE POLICY "only users can view and edit their helicone keys" ON "public"."helicone_api_keys"
AS PERMISSIVE FOR ALL
TO public
USING (((auth.uid() = user_id)))
WITH CHECK (((auth.uid() = user_id)))